package com.cxy.ch1;

import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;

/**
 * 
 * @ClassName: OnlyMain
 * @Description: TODO(ֻ��һ��main�����ĳ���)
 * @author ����Ѽ
 * @date 2020��4��12��
 *
 */
public class OnlyMain {
	public static void main(String[] args) {
		// java������߳�ϵͳ�Ĺ���ӿ�
		ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
		// ����Ҫ��ȡͬ����monitor��synchronizer��Ϣ��������ȡ�̺߳��̵߳Ķ�ջ��Ϣ
		ThreadInfo[] threadInfos = threadMXBean.dumpAllThreads(false, false);
		// �����߳���Ϣ������ӡ�߳�ID���߳�������Ϣ
		for (ThreadInfo threadInfo : threadInfos) {
			System.out.println("[" + threadInfo.getThreadId() + "]" + threadInfo.getThreadName());
		}
	}
	/**
	 * ��ӡ��Ϣ���£� [5]Attach Listener --��ȡ�ڴ���Ϣ [4]Signal Dispatcher [3]Finalizer
	 * --�ػ��߳� [2]Reference Handler [1]main --���߳�
	 */
}
